package com.ct.controller.state;

import com.ct.application.state.IStateService;
import com.ct.commons.BaseController;
import com.ct.commons.annotation.ApiLog;
import com.ct.commons.annotation.PermissionApi;
import com.ct.state.model.StateCardModel;
import com.ct.state.model.StateOrderModel;
import com.ct.state.model.StateOsBroswerModel;
import com.ct.state.model.StateProvinceCityModel;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * 控制面板-统计分析
 */
@RestController
@PermissionApi(title = "统计分析模块",path="/api/v1/state",code = "K1000",sorted = 6)
public class StateController extends BaseController {

    @Resource
    private IStateService stateService;

    /**
     * 统计四个卡片数据信息
     *
     * @return
     */
    @PostMapping("/state/card")
    @ApiLog("统计卡片数据信息")
    @PermissionApi(title = "统计卡片数据信息",path="/api/v1/state/card",code = "K1001",sorted = 1)
    public StateCardModel stateCard() {
        return stateService.stateCard();
    }

    /**
     * 统计订单占比
     *
     * @param type
     * @return
     */
    @PostMapping("/state/order")
    @PermissionApi(title = "统计订单占比",path="/api/v1/state/order",code = "K1002",sorted = 2)
    public List<StateOrderModel> stateOrderData(@RequestParam(name = "type", defaultValue = "month") String type) {
        return stateService.stateOrderData(type);
    }

    /**
     * 统计用户城市占比
     *
     * @param type
     * @return
     */
    @PostMapping("/state/provincecity")
    @ApiLog("统计用户城市占比")
    @PermissionApi(title = "统计用户城市占比",path="/api/v1/state/provincecity",code = "K1003",sorted = 3)
    public List<StateProvinceCityModel> statePCData(@RequestParam(name = "type", defaultValue = "city") String type) {
        return stateService.statePCData(type);
    }

    /**
     * 统计浏览器
     *
     * @return
     */
    @PostMapping("/state/broswer")
    @PermissionApi(title = "统计浏览器",path="/api/v1/state/broswer",code = "K1004",sorted = 4)
    public List<StateOsBroswerModel> statePlatformDataBroswer() {
        return stateService.statePlatformDataBroswer();
    }

    /**
     * 统计os
     *
     * @return
     */
    @PostMapping("/state/os")
    @PermissionApi(title = "统计os",path="/api/v1/state/os",code = "K1005",sorted = 5)
    public List<StateOsBroswerModel> statePlatformDataOS() {
        return stateService.statePlatformDataOS();
    }

}
